#include "PCResource_theme_bilibili.h"

typedef struct 
{
  lv_obj_t *usage_label;
  lv_obj_t *usage_lightning_img;
  lv_obj_t *usage_bar_img;
  lv_obj_t *used_label;
}ram_obj_t;

typedef struct
{
  lv_obj_t *freq_chart;
  lv_obj_t *freq_label;
  lv_obj_t *temp_chart;
  lv_obj_t *temp_label;
}gpu_obj_t;

typedef struct
{
  lv_obj_t *temp_chart;
  lv_obj_t *temp_label;
}disk_obj_t;

enum
{
  CPU_LABEL_FREQ = 0,
  CPU_LABEL_POWER,
  CPU_LABEL_FAN,
  CPU_LABEL_TEMP,
};


LV_FONT_DECLARE(lv_font_miao_16)
LV_FONT_DECLARE(lv_font_miao_25)
LV_FONT_DECLARE(lv_font_miao_30)
LV_FONT_DECLARE(lv_font_miao_60)
LV_FONT_DECLARE(lv_font_tiger_24)
LV_FONT_DECLARE(lv_font_tiger_30)
LV_FONT_DECLARE(lv_font_tiger_40)

#define ICON_PATH "S:./res/pc_resource/icon/bilibili/"
#define CIRCLE_MAX 15     //圆图像资源最大索引
#define CRICLE_FILE_FMT "circle%s.bin"

#define BAR_MAX 14      //进度条图像资源最大索引
#define BAR_FILE_FMT "bar%s.bin"

#define LIGHTNING_MAX 15    //闪电图像资源最大索引
#define LIGHTNING_FILE_FMT "lightning%s.bin"

#define RAM_USAGE_FMT "内存使用率   #ffffff %d# %%"
#define RAM_USED_FMT "已用内存 #ffffff %d# MB"

static void pc_resource_gui_bilibili_theme_init(lv_obj_t *parent, gui_opt_t *opts);
static void pc_resource_gui_bilibili_theme_update(PCResInfo *info);
static void pc_resource_gui_bilibili_theme_release(void);
static void pc_resource_gui_bilibili_transpobj_click_event_cb(lv_event_t *e);
static void pc_resource_gui_bilibili_transpobj_long_press_event_cb(lv_event_t *e);

gui_theme_operations bilibili_theme =
{
  .init = pc_resource_gui_bilibili_theme_init,
  .update = pc_resource_gui_bilibili_theme_update,
  .release = pc_resource_gui_bilibili_theme_release,
};

// 回调函数集合
static gui_opt_t *gui_opts;

// 背景图片
static lv_obj_t *back_img;

// 时间标签
static lv_obj_t *time_label;

//透明对象，用于点击交互
static lv_obj_t *transp_obj;

//CPU/GPU/DISK使用率圆弧img
static lv_obj_t *usage_arc_img[3];

//内存区域控件集合
static ram_obj_t ram_obj;

//CPU区域数据标签集合
static lv_obj_t *cpu_label[4];

//上传下载速率标签
static lv_obj_t *netspeed_label[2];

//GPU区域控件集合
static gpu_obj_t gpu_obj;

//硬盘区域控件集合
static disk_obj_t disk_obj;

//图表样式
static lv_style_t chart_style;

//图表标签样式
static lv_style_t chart_label_style;

//CPU区域数据标签文本
static const char *cpu_label_title_text[4] = 
{
  "CPU 频率    MHz", "CPU 功率    W", "CPU 风扇    RPM", "CPU 温度    ℃"
};

//CPU区域数据标签文本坐标
static const lv_coord_t cpu_label_title_pos[4][2] = 
{
  {42, 288}, {42, 325}, {42, 361}, {42, 394}
};

//CPU/GPU/DISK使用率圆弧坐标
static const lv_coord_t usage_arc_img_pos[3][2] = 
{
  {239, 306}, {859, 44}, {859, 420}
};

//CPU/GPU使用率圆弧标题
static const char *usage_arc_title[3] = 
{
  "CPU使用率", "GPU使用率", "使用率"
};

/**
 *@brief bilibili主题初始化函数
 */
static void pc_resource_gui_bilibili_theme_init(lv_obj_t *parent, gui_opt_t *opts)
{
  gui_opts = opts;

  //创建图表主样式
  lv_style_init(&chart_style);
  lv_style_set_line_color(&chart_style, lv_color_hex(0x0080ff));    //网格线条颜色
  lv_style_set_border_color(&chart_style, lv_color_hex(0x0080ff));    //边框颜色
  lv_style_set_border_width(&chart_style, 1);   //边框宽度
  lv_style_set_bg_opa(&chart_style, LV_OPA_TRANSP);   //背景透明
  lv_style_set_radius(&chart_style, 0);   //边框圆角半径
  lv_style_set_pad_all(&chart_style, 0);    //内部填充宽度

  //创建图表标签主样式
  lv_style_init(&chart_label_style);
  lv_style_set_text_font(&chart_label_style, &lv_font_tiger_24);
  lv_style_set_text_color(&chart_label_style, lv_color_hex(0x82cef5));

  // 创建背景图片;
  back_img = lv_img_create(parent);
  lv_obj_set_size(back_img, 1024, 600);
  lv_img_set_src(back_img, "S:./res/pc_resource/background/bilibilibg.bin");
  lv_obj_center(back_img);

  //创建3个使用率圆弧img
  for(int i = 0; i < 3; i++)
  {
    lv_obj_t *img = lv_img_create(back_img);
    lv_obj_set_size(img, 120, 120);
    lv_obj_set_pos(img, usage_arc_img_pos[i][0], usage_arc_img_pos[i][1]);
    lv_img_set_src(img, ICON_PATH "circle0.bin");

    //创建圆弧标题
    lv_obj_t *title = lv_label_create(back_img);
    lv_obj_set_style_text_font(title, &lv_font_tiger_24, LV_STATE_DEFAULT);       // 设置字体
    lv_obj_set_style_text_opa(title, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
    lv_obj_set_style_text_color(title, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
    lv_label_set_text_static(title, usage_arc_title[i]);
    lv_obj_align_to(title, img, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);

    lv_obj_t *label = lv_label_create(img);
    lv_obj_set_style_text_font(label, &lv_font_tiger_40, LV_STATE_DEFAULT);       // 设置字体
    lv_obj_set_style_text_opa(label, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
    lv_obj_set_style_text_color(label, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
    lv_label_set_text(label, "0");
    lv_obj_center(label);

    lv_obj_set_user_data(img, label);   //label绑定圆弧
    usage_arc_img[i] = img;
  }

  //创建内存区域控件
  lv_obj_t *obj = lv_label_create(back_img);    //创建内存使用率标签
  lv_label_set_recolor(obj, true);    //开启重绘色
  lv_obj_set_style_text_font(obj, &lv_font_tiger_40, LV_STATE_DEFAULT);       // 设置字体
  lv_obj_set_style_text_opa(obj, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
  lv_obj_set_style_text_color(obj, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
  lv_label_set_text_fmt(obj, RAM_USAGE_FMT, 0);
  lv_obj_set_pos(obj, 81, 485);
  ram_obj.usage_label = obj;

  obj = lv_img_create(back_img);    //创建内存使用率小闪电
  lv_obj_set_size(obj, 120, 120);
  lv_obj_set_pos(obj, 233, 440);
  lv_img_set_src(obj, ICON_PATH "lightning0.bin");
  ram_obj.usage_lightning_img = obj;

  obj = lv_img_create(back_img);    //创建内存使用率 进度条
  lv_obj_set_size(obj, 360, 11);
  lv_obj_set_pos(obj, 80, 564);
  lv_img_set_src(obj, ICON_PATH "bar0.bin");
  ram_obj.usage_bar_img = obj;

  obj = lv_label_create(back_img);    //创建内存使用量标签
  lv_label_set_recolor(obj, true);    //开启重绘色
  lv_obj_set_style_text_font(obj, &lv_font_tiger_24, LV_STATE_DEFAULT);       // 设置字体
  lv_obj_set_style_text_opa(obj, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
  lv_obj_set_style_text_color(obj, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
  lv_label_set_text_fmt(obj, RAM_USED_FMT, 0);
  lv_obj_align_to(obj, ram_obj.usage_bar_img, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
  ram_obj.used_label = obj;

  //创建CPU组件4个标签
  for(int i = 0; i < 4; i++)
  {
    lv_obj_t *title = lv_label_create(back_img);    //创建标题
    lv_obj_set_style_text_font(title, &lv_font_tiger_24, LV_STATE_DEFAULT);       // 设置字体
    lv_obj_set_style_text_opa(title, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
    lv_obj_set_style_text_color(title, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
    lv_label_set_text_static(title, cpu_label_title_text[i]);
    lv_obj_set_pos(title, cpu_label_title_pos[i][0], cpu_label_title_pos[i][1]);

    lv_obj_t *label = lv_label_create(back_img);
    lv_obj_set_size(label, 50, 24);
    lv_obj_align_to(label, title, LV_ALIGN_LEFT_MID, 100, 0);
    lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, LV_STATE_DEFAULT);   //设置对齐方式
    lv_obj_set_style_text_font(label, &lv_font_tiger_24, LV_STATE_DEFAULT);       // 设置字体
    lv_obj_set_style_text_opa(label, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
    lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), LV_STATE_DEFAULT); // 字体颜色
    lv_label_set_text(label, "0");

    cpu_label[i] = label;
  }
  
  //创建上传下载icon
  lv_obj_t *net_img = lv_img_create(back_img);
  lv_img_set_src(net_img, ICON_PATH "updownload.bin");
  lv_obj_set_pos(net_img, 145, 124);

  //创建上传下载速率标签
  for(int i = 0; i < 2; i++)
  {
    lv_obj_t *label = lv_label_create(back_img);    //创建标签
    lv_label_set_recolor(label, true);    //开启重绘色
    lv_obj_set_style_text_font(label, &lv_font_tiger_24, LV_STATE_DEFAULT);       // 设置字体
    lv_obj_set_style_text_opa(label, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
    lv_obj_set_style_text_color(label, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色

    netspeed_label[i] = label;
  }
  lv_label_set_text_fmt(netspeed_label[0], "上传 #ffffff %d#KB/s", 0);
  lv_label_set_text_fmt(netspeed_label[1], "下载 #ffffff %d#KB/s", 0);
  lv_obj_align_to(netspeed_label[0], net_img, LV_ALIGN_OUT_RIGHT_TOP, 0, 25);
  lv_obj_align_to(netspeed_label[1], net_img, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, -25);

  //创建GPU区域控件
  gpu_obj.freq_chart = lv_chart_create(back_img);   //创建GPU核心频率图表
  lv_chart_set_div_line_count(gpu_obj.freq_chart, 5, 30);
  lv_chart_set_type(gpu_obj.freq_chart, LV_CHART_TYPE_LINE);
  lv_chart_set_update_mode(gpu_obj.freq_chart, LV_CHART_UPDATE_MODE_SHIFT);  
  lv_chart_set_point_count(gpu_obj.freq_chart, 55);        //点数55
  lv_chart_series_t *series = lv_chart_add_series(gpu_obj.freq_chart, lv_color_hex(0xffffff), LV_CHART_AXIS_PRIMARY_Y);
  lv_obj_set_user_data(gpu_obj.freq_chart, series);      //保存系列
  lv_chart_set_all_value(gpu_obj.freq_chart, series, 0);   //初始化所有数值
  lv_obj_add_event_cb(gpu_obj.freq_chart, chart_draw_evnet_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
  lv_obj_set_size(gpu_obj.freq_chart, 220, 50);
  lv_obj_remove_style(gpu_obj.freq_chart, NULL, LV_PART_INDICATOR);      //移除折线图数据点
  lv_obj_add_style(gpu_obj.freq_chart, &chart_style, LV_STATE_DEFAULT);    //添加图表主样式
  lv_obj_set_pos(gpu_obj.freq_chart, 625, 65);

  gpu_obj.temp_chart = lv_chart_create(back_img);   //创建GPU温度图表
  lv_chart_set_div_line_count(gpu_obj.temp_chart, 5, 30);
  lv_chart_set_type(gpu_obj.temp_chart, LV_CHART_TYPE_LINE);
  lv_chart_set_update_mode(gpu_obj.temp_chart, LV_CHART_UPDATE_MODE_SHIFT);  
  lv_chart_set_point_count(gpu_obj.temp_chart, 50);        //点数
  series = lv_chart_add_series(gpu_obj.temp_chart, lv_color_hex(0xffffff), LV_CHART_AXIS_PRIMARY_Y);
  lv_obj_set_user_data(gpu_obj.temp_chart, series);      //保存系列
  lv_chart_set_all_value(gpu_obj.temp_chart, series, 0);   //初始化所有数值
  lv_obj_add_event_cb(gpu_obj.temp_chart, chart_draw_evnet_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
  lv_obj_set_size(gpu_obj.temp_chart, 200, 50);
  lv_obj_remove_style(gpu_obj.temp_chart, NULL, LV_PART_INDICATOR);      //移除折线图数据点
  lv_obj_add_style(gpu_obj.temp_chart, &chart_style, LV_STATE_DEFAULT);    //添加图表主样式
  lv_obj_set_pos(gpu_obj.temp_chart, 645, 144);

  gpu_obj.freq_label = lv_label_create(back_img);   //创建GPU频率标签
  lv_label_set_recolor(gpu_obj.freq_label, true);    //开启重绘色
  lv_obj_add_style(gpu_obj.freq_label, &chart_label_style, LV_STATE_DEFAULT);   //添加样式
  lv_label_set_text_fmt(gpu_obj.freq_label, "GPU核心频率 #ffffff %d# MHz", 0);
  lv_obj_align_to(gpu_obj.freq_label, gpu_obj.freq_chart, LV_ALIGN_OUT_TOP_MID, 0, 0);

  gpu_obj.temp_label = lv_label_create(back_img);   //创建GPU温度标签
  lv_label_set_recolor(gpu_obj.temp_label, true);    //开启重绘色
  lv_obj_add_style(gpu_obj.temp_label, &chart_label_style, LV_STATE_DEFAULT);   //添加样式
  lv_label_set_text_fmt(gpu_obj.temp_label, "GPU 温度 #ffffff %d# ℃", 0);
  lv_obj_align_to(gpu_obj.temp_label, gpu_obj.temp_chart, LV_ALIGN_OUT_TOP_MID, 0, 0);

  //创建硬盘区域控件
  lv_obj_t *disk_title = lv_label_create(back_img);   //创建区域标题
  lv_obj_set_style_text_font(disk_title, &lv_font_tiger_40, LV_STATE_DEFAULT);       // 设置字体
  lv_obj_set_style_text_opa(disk_title, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
  lv_obj_set_style_text_color(disk_title, lv_color_hex(0x82cef5), LV_STATE_DEFAULT); // 字体颜色
  lv_label_set_text(disk_title, "硬盘");
  lv_obj_set_pos(disk_title, 665, 390);

  disk_obj.temp_chart = lv_chart_create(back_img);   //创建DISK温度图表
  lv_chart_set_div_line_count(disk_obj.temp_chart, 8, 30);
  lv_chart_set_type(disk_obj.temp_chart, LV_CHART_TYPE_LINE);
  lv_chart_set_update_mode(disk_obj.temp_chart, LV_CHART_UPDATE_MODE_SHIFT);  
  lv_chart_set_point_count(disk_obj.temp_chart, 50);        //点数
  series = lv_chart_add_series(disk_obj.temp_chart, lv_color_hex(0xffffff), LV_CHART_AXIS_PRIMARY_Y);
  lv_obj_set_user_data(disk_obj.temp_chart, series);      //保存系列
  lv_chart_set_all_value(disk_obj.temp_chart, series, 0);   //初始化所有数值
  lv_obj_add_event_cb(disk_obj.temp_chart, chart_draw_evnet_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
  lv_obj_set_size(disk_obj.temp_chart, 200, 80);
  lv_obj_remove_style(disk_obj.temp_chart, NULL, LV_PART_INDICATOR);      //移除折线图数据点
  lv_obj_add_style(disk_obj.temp_chart, &chart_style, LV_STATE_DEFAULT);    //添加图表主样式
  lv_obj_set_pos(disk_obj.temp_chart, 650, 475);

  disk_obj.temp_label = lv_label_create(back_img);   //创建DISK温度标签
  lv_label_set_recolor(disk_obj.temp_label, true);    //开启重绘色
  lv_obj_add_style(disk_obj.temp_label, &chart_label_style, LV_STATE_DEFAULT);   //添加样式
  lv_label_set_text_fmt(disk_obj.temp_label, "温度 #ffffff %d# ℃", 0);
  lv_obj_align_to(disk_obj.temp_label, disk_obj.temp_chart, LV_ALIGN_OUT_TOP_MID, 0, 0);

  // 创建时间标签
  time_label = lv_label_create(back_img);
  lv_obj_set_style_text_font(time_label, &lv_font_tiger_40, LV_STATE_DEFAULT);       // 设置字体
  lv_obj_set_style_text_opa(time_label, LV_OPA_COVER, LV_STATE_DEFAULT);                // 字体透明度
  lv_obj_set_style_text_color(time_label, lv_color_hex(0xffffff), LV_STATE_DEFAULT); // 字体颜色
  lv_label_set_text(time_label, "00:00 2023/1/1");
  lv_obj_set_pos(time_label, 118, 93);

  //创建透明对象
  transp_obj = lv_obj_create(back_img);
  lv_obj_set_size(transp_obj, 171, 144);
  lv_obj_set_pos(transp_obj, 376, 212);
  lv_obj_set_style_bg_opa(transp_obj, LV_OPA_TRANSP, LV_STATE_DEFAULT);
  lv_obj_set_style_border_opa(transp_obj, LV_OPA_TRANSP, LV_STATE_DEFAULT);

  // 为时间标签添加事件回调
  lv_obj_add_flag(transp_obj, LV_OBJ_FLAG_CLICKABLE);
  lv_obj_add_event_cb(transp_obj, pc_resource_gui_bilibili_transpobj_click_event_cb,
                      LV_EVENT_SHORT_CLICKED, NULL);
  lv_obj_add_event_cb(transp_obj, pc_resource_gui_bilibili_transpobj_long_press_event_cb,
                      LV_EVENT_LONG_PRESSED, NULL);
}

/**
 *@brief bilibili主题数据更新函数
 */
static void pc_resource_gui_bilibili_theme_update(PCResInfo *info)
{
  char path[64];

  //更新CPU/GPU/DISK使用率圆弧img
  lv_snprintf(path, sizeof(path), ICON_PATH "circle%d.bin", info->cpu_usage * CIRCLE_MAX / 100);
  lv_img_set_src(usage_arc_img[0], path);
  lv_obj_t *usage_label = lv_obj_get_user_data(usage_arc_img[0]);
  lv_label_set_text_fmt(usage_label, "%d", info->cpu_usage);

  lv_snprintf(path, sizeof(path), ICON_PATH "circle%d.bin", info->gpu_usage * CIRCLE_MAX / 100);
  lv_img_set_src(usage_arc_img[1], path);
  usage_label = lv_obj_get_user_data(usage_arc_img[1]);
  lv_label_set_text_fmt(usage_label, "%d", info->gpu_usage);

  lv_snprintf(path, sizeof(path), ICON_PATH "circle%d.bin", info->disk_usage * CIRCLE_MAX / 100);
  lv_img_set_src(usage_arc_img[2], path);
  usage_label = lv_obj_get_user_data(usage_arc_img[2]);
  lv_label_set_text_fmt(usage_label, "%d", info->disk_usage);

  //更新内存区域数据
  lv_snprintf(path, sizeof(path), ICON_PATH "lightning%d.bin", info->ram_usage * LIGHTNING_MAX / 100);
  lv_img_set_src(ram_obj.usage_lightning_img, path);
  lv_label_set_text_fmt(ram_obj.usage_label, RAM_USAGE_FMT, info->ram_usage);

  lv_snprintf(path, sizeof(path), ICON_PATH "bar%d.bin", info->ram_usage * BAR_MAX / 100);
  lv_img_set_src(ram_obj.usage_bar_img, path);
  lv_label_set_text_fmt(ram_obj.used_label, RAM_USED_FMT, info->ram_used);

  //更新CPU区域标签
  lv_label_set_text_fmt(cpu_label[CPU_LABEL_FREQ], "%d", info->cpu_freq);
  lv_label_set_text_fmt(cpu_label[CPU_LABEL_POWER], "%d.%d", info->cpu_power / 10, info->cpu_power % 10);
  lv_label_set_text_fmt(cpu_label[CPU_LABEL_FAN], "%d", info->cpu_fan_speed);
  lv_label_set_text_fmt(cpu_label[CPU_LABEL_TEMP], "%d", info->cpu_temp);

  //更新GPU区域信息
  lv_label_set_text_fmt(gpu_obj.freq_label, "GPU核心频率 #ffffff %d# MHz", info->gpu_freq);
  lv_label_set_text_fmt(gpu_obj.temp_label, "GPU 温度 #ffffff %d# ℃", info->gpu_temp);

  lv_chart_series_t *gpu_freq_series = lv_obj_get_user_data(gpu_obj.freq_chart);
  lv_chart_set_next_value(gpu_obj.freq_chart, gpu_freq_series, info->gpu_freq);

  lv_chart_series_t *gpu_temp_series = lv_obj_get_user_data(gpu_obj.temp_chart);
  lv_chart_set_next_value(gpu_obj.temp_chart, gpu_temp_series, info->gpu_temp);

  //更新DISK区域信息
  lv_label_set_text_fmt(disk_obj.temp_label, "温度 #ffffff %d# ℃", info->disk_temp);

  lv_chart_series_t *disk_temp_series = lv_obj_get_user_data(disk_obj.temp_chart);
  lv_chart_set_next_value(disk_obj.temp_chart, disk_temp_series, info->disk_temp);

  lv_obj_t *charts[] = {
    gpu_obj.freq_chart, gpu_obj.temp_chart, disk_obj.temp_chart
  };
  lv_chart_series_t *series_array[] = {
    gpu_freq_series, gpu_temp_series, disk_temp_series
  };

  int default_max[] = {
    400, 40, 40
  };

  //图表自动刻度计算
  for(int i = 0; i < sizeof(charts) / sizeof(charts[0]); i++)
    chart_auto_scale(charts[i], series_array[i], 0, default_max[i]);
  

  //更新上传下载速率
  int up_keep_mininum = 1;
  int down_keep_mininum = 1;
  int up = info->net_upload_speed;
  int down = info->net_download_speed;
  char *up_unit = NULL;
  char *down_unit = NULL;

  if (up > 100000) // 大于10MB/s
    up_keep_mininum = 10;

  if (down > 100000)
    down_keep_mininum = 10;

  if (up > 1000) // 大于100KB/s
  {
    up /= 100;
    up_unit = "MB/s";        // 单位变换
  }
  else
    up_unit = "KB/s";

  if (down > 1000)
  {
    down /= 100;  
    down_unit = "MB/s";       // 单位变换
  }
  else
    down_unit = "KB/s";           // 单位变换

  lv_label_set_text_fmt(netspeed_label[0], "上传 #ffffff %d.%d#%s", up / 100, up % 100 / up_keep_mininum, up_unit);
  lv_label_set_text_fmt(netspeed_label[1], "下载 #ffffff %d.%d#%s", down / 100, down % 100 / down_keep_mininum, down_unit);

  // 更新时间显示
  char time[6] = {"00:00"};

  time[0] += info->hour / 10;
  time[1] += info->hour % 10;
  time[3] += info->min / 10;
  time[4] += info->min % 10;

  lv_label_set_text_fmt(time_label, "%s %d/%d/%d", time, info->year, info->month, info->date);
}

/**
 *@brief bilibili主题释放函数
 */
static void pc_resource_gui_bilibili_theme_release(void)
{
  lv_obj_del_async(back_img);
}

/**
 *@brief 透明对象单击事件回调函数
 */
static void pc_resource_gui_bilibili_transpobj_click_event_cb(lv_event_t *e)
{
  if (gui_opts != NULL && gui_opts->set_next_theme != NULL)
    gui_opts->set_next_theme();
}

/**
 *@brief 透明对象长按事件回调函数
 */
static void pc_resource_gui_bilibili_transpobj_long_press_event_cb(lv_event_t *e)
{
  if (gui_opts != NULL && gui_opts->exit_cb != NULL)
    gui_opts->exit_cb(e);
}
